Checkpointing for increasing efficiency of a blockchain

ABSTRACT

An example operation may include one or more of retrieving, into a new node to be instantiated in a blockchain network, a state database checkpoint of a state database created at a block number of a blockchain of the blockchain network, retrieving, into the new node, blocks of the blockchain from the checkpoint block number to a current block number, constructing an initial state database from the received state database checkpoint, and executing, at the new node, the transactions of the retrieved blocks on the initial state database to generate a current state database.

TECHNICAL FIELD

This application generally relates to a database storage system, andmore particularly, to checkpointing for increasing efficiency of ablockchain.

BACKGROUND

A centralized database stores and maintains data in one single database(e.g., database server) at one location. This location is often acentral computer, for example, a desktop central processing unit (CPU),a server CPU, or a mainframe computer. Information stored on acentralized database is typically accessible from multiple differentpoints. Multiple users or client workstations can work simultaneously onthe centralized database, for example, based on a client/serverconfiguration. A centralized database is easy to manage, maintain, andcontrol, especially for purposes of security because of its singlelocation. Within a centralized database, data redundancy is minimized asa single storing place of all data also implies that a given set of dataonly has one primary record.

However, a centralized database suffers from significant drawbacks. Forexample, a centralized database has a single point of failure. Inparticular, if there are no fault-tolerance considerations and ahardware failure occurs (for example a hardware, firmware, and/or asoftware failure), all data within the database is lost and work of allusers is interrupted. In addition, centralized databases are highlydependent on network connectivity. As a result, the slower theconnection, the amount of time needed for each database access isincreased. Another drawback is the occurrence of bottlenecks when acentralized database experiences high traffic due to a single location.Furthermore, a centralized database provides limited access to databecause only one copy of the data is maintained by the database. As aresult, multiple devices cannot access the same piece of data at thesame time without creating significant problems or risk overwritingstored data. Furthermore, because a database storage system has minimalto no data redundancy, data that is unexpectedly lost is very difficultto retrieve other than through manual operation from back-up storage.

Blockchains provide many advantages over a conventional centralizeddatabase. In a blockchain network, transaction data is provided to adistributed network of peer nodes. Each peer node stores a copy of thedatabase or ledger as a set of key/value pairs. Users of the networkprovide transaction data for new transactions to one or more of thepeers. Entities within the network, which may be peer nodes, verify thetransaction. At an appropriate juncture depending on the operationalconfiguration of a blockchain network, a peer will form a set ofverified pending transactions into a data block. The data block includesdata, such as a cryptographic hash, linking the block to a previous datablock, thereby forming a chain of data blocks, referred to as ablockchain. The newly formed data block is communicated to other peersof the network who update their version of the blockchain and state ofthe database.

Advantages of a blockchain include the removal of a central trustedauthority. Immutability of the ledger is also achieved via thecryptographic hash links from one data block to the next. However,blockchain networks are not without their drawbacks.

When a new node wishes to join the network, there can be a long durationrequired to bootstrap the new node. Typically, a new node has tovalidate and commit each transaction from block 1 to the current block.If there are millions of committed transactions, the time taken for anew peer to sync the state of the database could be hours/days.

A further disadvantage can be that significant consumption of storagecapacity may be required for peer nodes in long running blockchainnetworks. When a blockchain platform committed a lot of transactions,the storage capacity would increase significantly due to both BlockStorage including multiple certificates & signatures, read/write set,etc. and storage of the State Database including the key/value pairs inthe write set and associated indexing structure. Hard disk drive storageis (HDD) is cheaper but block storage and state database on a solidstate drive (SSD) would improve the blockchain performance significantlyas they are being used in a critical performance path. Until a block iswritten and flushed to the disk, peer does not update the statedatabase. Until valid write sets are written to the state database, peercannot process the next block and transactions cannot be simulated.

A further problem is a lack of confirmation on State Convergence aftervalidation and commit of a block to the blockchain. A peer can go out ofsync with other peers in the blockchain network due to corrupt disk orsome unknown reasons. As there is no verification on the state changesafter committing a block, there is no early way to identify statedivergence.

There may be a problem with longer duration to recovery from a diskcorruption or fork in the blockchain/State database. Similar tobootstrapping a new node, when there is a disk corruption or a fork inthe blockchain, it is required to reconstruct the state by executing alltransactions since block 1 to the current block which may take hours todays on a long running blockchain network.

What is required is an improved method for operating a blockchain.

SUMMARY

One example embodiment provides a system that includes a blockchainnetwork comprising a plurality of peer nodes. One or more of the peernodes comprise a processor and memory and are programmed to store ablockchain and a state database comprising a plurality of key/valuepairs, wherein one or more of the plurality of peer nodes are programmedto perform one or more of generate a state database checkpoint, obtainconsensus on the state database checkpoint, and store the state databasecheckpoint.

One example embodiment provides a system that includes a blockchainnetwork comprising a plurality of peer nodes. One or more of the peernodes comprise a processor and memory and are programmed to store ablockchain and a state database comprising a plurality of key/valuepairs, wherein one or more of the plurality of peer nodes are programmedto perform one or more of determine that the node is a corrupted nodethat is at least one of corrupted or forked, retrieve a state databasecheckpoint of a state database created at a block number of theblockchain, retrieve blocks of the blockchain from the checkpoint blocknumber to a current block number, construct an initial state databasefrom the received state database checkpoint, and execute thetransactions of the retrieved blocks on the initial state database togenerate a current state database.

One example embodiment provides a system that includes a blockchainnetwork comprising a plurality of peer nodes. One or more of the peernodes comprise a processor and memory and are programmed to store ablockchain and a state database comprising a plurality of key/valuepairs, wherein one or more of the plurality of peer nodes are programmedto perform one or more of retrieve a state database checkpoint of astate database created at a block number of the blockchain, retrieveblocks of the blockchain from the checkpoint block number to a currentblock number, construct an initial state database from the receivedstate database checkpoint, and execute the transactions of the retrievedblocks on the initial state database to generate a current statedatabase.

Another example embodiment provides a method that includes one or moreof in one or more peer nodes of a plurality of peer nodes of ablockchain network that stores a blockchain and a state database,periodically generating a state database checkpoint, obtaining aconsensus on the state database checkpoint from one or more of the oneor more peer nodes, and storing the consensus state database checkpoint.

Another example embodiment provides a method that includes one or moreof retrieving, into a corrupted node in a blockchain network that is atleast one corrupted or forked, a state database checkpoint of a statedatabase created at a block number of a blockchain of the blockchainnetwork, wherein the retrieved state database checkpoint comprises alast known non-corrupted or non-forked checkpoint state, retrieving,into the corrupted node, blocks of the blockchain from the checkpointblock number to a current block number, constructing an initial statedatabase from the retrieved state database checkpoint, and executing, atthe corrupted node, the transactions of the retrieved blocks on theinitial state database to generate a current state database.

Another example embodiment provides a method that includes one or moreof retrieving, into a new node to be instantiated in a blockchainnetwork, a state database checkpoint of a state database created at ablock number of a blockchain of the blockchain network, retrieving, intothe new node, blocks of the blockchain from the checkpoint block numberto a current block number, constructing an initial state database fromthe received state database checkpoint, and executing, at the new node,the transactions of the retrieved blocks on the initial state databaseto generate a current state database.

A further example embodiment provides a non-transitory computer readablemedium comprising instructions, that when read by a processor, cause theprocessor to perform one or more of periodically generating a statedatabase checkpoint for a state database and blockchain maintained by apeer node of a blockchain network, obtaining a consensus on the statedatabase checkpoint from one or more of a plurality of peer nodes of theblockchain network, and storing the consensus state database checkpoint.

A further example embodiment provides a non-transitory computer readablemedium comprising instructions, that when read by a processor, cause theprocessor to perform one or more of retrieving, into a corrupted node ina blockchain network that is at least one or corrupted or forked, astate database checkpoint of a state database created at a block numberof a blockchain of the blockchain network, retrieving, into thecorrupted node, blocks of the blockchain from the checkpoint blocknumber to a current block number, constructing an initial state databasefrom the received state database checkpoint, and executing, at thecorrupted node, the transactions of the retrieved blocks on the initialstate database to generate a current state database.

A further example embodiment provides a non-transitory computer readablemedium comprising instructions, that when read by a processor, cause theprocessor to perform one or more of retrieving, into a new node to beinstantiated in a blockchain network, a state database checkpoint of astate database created at a block number of a blockchain of theblockchain network, retrieving, into the new node, blocks of theblockchain from the checkpoint block number to a current block number,constructing an initial state database from the received state databasecheckpoint, and executing, at the new node, the transactions of theretrieved blocks on the initial state database to generate a currentstate database.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates a network diagram of a system including a database,according to example embodiments.

FIG. 2A illustrates an example peer node configuration, according toexample embodiments.

FIG. 2B illustrates a further peer node configuration, according toexample embodiments.

FIG. 3 illustrates a permissioned network, according to exampleembodiments.

FIG. 4 illustrates a system messaging diagram, according to exampleembodiments.

FIG. 5A illustrates a flow diagram, according to example embodiments.

FIG. 5B illustrates an example merkle tree, according to exampleembodiments.

FIG. 5C illustrates an example merkle tree generated using an indexbased incremental hash computation method, according to exampleembodiments.

FIG. 5D illustrates an example merkle tree generated using a hashfunction based incremental hash computation method, according to exampleembodiments.

FIG. 5E illustrates a process for instantiating a new peer node on ablockchain network, according to example embodiments.

FIG. 5F illustrates a process for archiving data of a blockchain,according to example embodiments.

FIG. 5G illustrates a process for corrupt disk recovery at a peer node,according to example embodiments.

FIG. 5H illustrates a process for isolating leaf nodes causing a merkletree discrepancy to detect and recover from a fork, according to exampleembodiments.

FIG. 6A illustrates an example system configured to perform one or moreoperations described herein, according to example embodiments.

FIG. 6B illustrates a further example system configured to perform oneor more operations described herein, according to example embodiments.

FIG. 6C illustrates a smart contract configuration among contractingparties and a mediating server configured to enforce the smart contractterms on the blockchain according to example embodiments.

FIG. 6D illustrates another an additional example system, according toexample embodiments.

FIG. 7A illustrates a process of new data being added to a database,according to example embodiments.

FIG. 7B illustrates contents a data block including the new data,according to example embodiments.

FIG. 8 illustrates an example system that supports one or more of theexample embodiments.

DETAILED DESCRIPTION

It will be readily understood that the instant components, as generallydescribed and illustrated in the figures herein, may be arranged anddesigned in a wide variety of different configurations. Thus, thefollowing detailed description of the embodiments of at least one of amethod, apparatus, non-transitory computer readable medium and system,as represented in the attached figures, is not intended to limit thescope of the application as claimed but is merely representative ofselected embodiments.

The instant features, structures, or characteristics as describedthroughout this specification may be combined in any suitable manner inone or more embodiments. For example, the usage of the phrases “exampleembodiments”, “some embodiments”, or other similar language, throughoutthis specification refers to the fact that a particular feature,structure, or characteristic described in connection with the embodimentmay be included in at least one embodiment. Thus, appearances of thephrases “example embodiments”, “in some embodiments”, “in otherembodiments”, or other similar language, throughout this specificationdo not necessarily all refer to the same group of embodiments, and thedescribed features, structures, or characteristics may be combined inany suitable manner in one or more embodiments.

In addition, while the term “message” may have been used in thedescription of embodiments, the application may be applied to many typesof network data, such as, packet, frame, datagram, etc. The term“message” also includes packet, frame, datagram, and any equivalentsthereof. Furthermore, while certain types of messages and signaling maybe depicted in exemplary embodiments they are not limited to a certaintype of message, and the application is not limited to a certain type ofsignaling.

Example embodiments provide methods, systems, components, non-transitorycomputer readable media, devices, and/or networks, which provide theability to create checkpoints for the state database and to perform peeroperations on the blockchain and the state database using thecheckpoint.

A decentralized database is a distributed storage system which includesmultiple nodes that communicate with each other. A blockchain is anexample of a decentralized database which includes an append-onlyimmutable data structure resembling a distributed ledger capable ofmaintaining records between mutually untrusted parties. The untrustedparties are referred to herein as peers or peer nodes. Each peermaintains a copy of the database records and no single peer can modifythe database records without a consensus being reached among thedistributed peers. For example, the peers may execute a consensusprotocol to validate blockchain storage transactions, group the storagetransactions into blocks, and build a hash chain over the blocks. Thisprocess forms the ledger by ordering the storage transactions, as isnecessary, for consistency. In a public or permission-less blockchain,anyone can participate without a specific identity. Public blockchainsoften involve native cryptocurrency and use consensus based on variousprotocols such as Proof of Work (PoW). On the other hand, a permissionedblockchain database provides a system which can secure inter-actionsamong a group of entities which share a common goal but which do notfully trust one another, such as businesses that exchange funds, goods,information, and the like.

A blockchain operates arbitrary, programmable logic, tailored to adecentralized storage scheme and referred to as “smart contracts” or“chaincodes.” In some cases, specialized chaincodes may exist formanagement functions and parameters which are referred to as systemchaincode. Smart contracts are trusted distributed applications whichleverage tamper-proof properties of the blockchain database and anunderlying agreement between nodes which is referred to as anendorsement or endorsement policy. In general, blockchain transactionstypically must be “endorsed” before being committed to the blockchainwhile transactions which are not endorsed are disregarded. A typicalendorsement policy allows chaincode to specify endorsers for atransaction in the form of a set of peer nodes that are necessary forendorsement. When a client sends the transaction to the peers specifiedin the endorsement policy, the transaction is executed to validate thetransaction. After validation, the transactions enter an ordering phasein which a consensus protocol is used to produce an ordered sequence ofendorsed transactions grouped into blocks.

Nodes are the communication entities of the blockchain system. A “node”may perform a logical function in the sense that multiple nodes ofdifferent types can run on the same physical server. Nodes are groupedin trust domains and are associated with logical entities that controlthem in various ways. Nodes may include different types, such as aclient or submitting-client node which submits a transaction-invocationto an endorser (e.g., peer), and broadcasts transaction-proposals to anordering service (e.g., ordering node). Another type of node is a peernode which can receive client submitted transactions, commit thetransactions and maintain a state and a copy of the ledger of blockchaintransactions. Peers can also have the role of an endorser, although itis not a requirement. An ordering-service-node or orderer is a noderunning the communication service for all nodes, and which implements adelivery guarantee, such as a broadcast to each of the peer nodes in thesystem when committing transactions and modifying a world state of theblockchain, which is another name for the initial blockchain transactionwhich normally includes control and setup information.

A ledger is a sequenced, tamper-resistant record of all statetransitions of a blockchain. State transitions may result from chaincodeinvocations (i.e., transactions) submitted by participating parties(e.g., client nodes, ordering nodes, endorser nodes, peer nodes, etc.).A transaction may result in a set of asset key-value pairs beingcommitted to the ledger as one or more operands, such as creates,updates, deletes, and the like. The ledger includes a blockchain (alsoreferred to as a chain) which is used to store an immutable, sequencedrecord in blocks. The ledger also includes a state database whichmaintains a current state of the blockchain. There is typically oneledger per channel. Each peer node maintains a copy of the ledger foreach channel of which they are a member.

A chain is a transaction log which is structured as hash-linked blocks,and each block contains a sequence of N transactions where N is equal toor greater than one. The block header includes a hash of the block'stransactions, as well as a hash of the prior block's header. In thisway, all transactions on the ledger may be sequenced andcryptographically linked together. Accordingly, it is not possible totamper with the ledger data without breaking the hash links. A hash of amost recently added blockchain block represents every transaction on thechain that has come before it, making it possible to ensure that allpeer nodes are in a consistent and trusted state. The chain may bestored on a peer node file system (i.e., local, attached storage, cloud,etc.), efficiently supporting the append-only nature of the blockchainworkload.

The current state of the immutable ledger represents the latest valuesfor all keys that are included in the chain transaction log. Because thecurrent state represents the latest key values known to a channel, it issometimes referred to as a world state. Chaincode invocations executetransactions against the current state data of the ledger. To make thesechaincode interactions efficient, the latest values of the keys may bestored in a state database. The state database may be simply an indexedview into the chain's transaction log, it can therefore be regeneratedfrom the chain at any time. The state database may automatically berecovered (or generated if needed) upon peer node startup, and beforetransactions are accepted.

Some benefits of the instant solutions described and depicted hereininclude the ability to reduce the operational burden on nodes of ablockchain network by storing consensus checkpoints at the node. Thecheckpoints allow efficiencies at the nodes including reduction in timeto instantiate a node, ability to quickly restore a corrupted or forkednode, and the ability to more efficiently store the blockchain at thenode.

One of the benefits of the example embodiments is that it improves thefunctionality of a computing system by improving the speed at which newnodes can join a blockchain and/or existing nodes can recover from diskerrors, chain forks, etc.

FIG. 1 illustrates a logic network diagram 100 of a blockchain networkaccording to example embodiments. Referring to FIG. 1, the network 100includes a plurality of peer nodes 102. Each peer node 102 includes atleast one processor 104 and an operatively associated memory 106. Thememory 106 may include memory for one or more instruction sets,applications, software etc. as well as memory for storing a blockchain108 and a state database or ledger 110. The memory 106 may also includerandom access memory for executing the one or more instruction sets,applications, software etc. to perform one or more functions of theblockchain network. The memory 106 may also include memory for storingdata including a blockchain and a state ledger database.

In accordance with example embodiments, the node 102 may also execute acheckpointer 112 that generates a checkpoint state 114 of the statedatabase. In one or more embodiments, the checkpointer 112 takes care ofdeterministically computing a state hash at a checkpoint interval (m)and also a tamper proof state dump (which would be the dump of allstates as of block height h, being a multiple of m. A consensus process116 may also execute once the checkpointer 112 has completed the hashcomputation to ensure that the checkpoint state 114 that is stored hasconsensus across the peer nodes 102 of the blockchain network 100 and todetect whether the node is corrupted or forked. It should be noted thatthe checkpoint consensus is a separate and distinct process to thetransaction consensus typically performed on blockchain transactions.The checkpoint 114 is a representation of the word state database 110 atsome previous point in time, e.g. at a particular block number of theblockchain. In particular embodiments as will be described in moredetail below, the checkpoint state 114 may be generated and stored as amerkle tree representation which has particular advantages fordetermining checkpoint consensus across the peer nodes of the network100. These advantages include parallel computation, storage of largeamount of data, supports incremental computation, and easy proof ofpresent state in the blockchain by sharing a very minimal state.Overall, these properties allow for a data structure to efficientlyarrive at a checkpoint and also generate a tamper proof state dump of alarge data set. However, some or all of the properties may not berequired or desired in all embodiments and other data structures may beequally viable. For example, a variety of hash trees can be used such asmerkle tree, red black merkle tree, tiger hash tree, etc.

In some embodiments, it may be possible to use other data structures,such as a simple data bucket or array data structure. For example, allstates may be collected in a data bucket and then a hash calculated forthe bucket. A checkpoint can be created on the hash and store the wholebucket along with the hash after consensus. While feasible, thisarrangement is less suitable for large data due to memory constraints,incremental computation is not possible and to prove that a particularstate is not tampered with, the whole of the data needs to be sent alongwith the hash.

The peer nodes are configured to communicate with each other via variousprotocols, including peer to peer protocols, through a communicationsnetwork. Typically, the communication network will include the internetand its associated protocols. The specific method by which the peernodes communicate is not considered pertinent to the present applicationand many forms of communication systems will be apparent to the personskilled in the art.

The particular form of the blockchain network 100 is not consideredpertinent to the present application. The blockchain network 100 mayexecute proof-of-work or proof-of-stake algorithms for committing newblocks to the blockchain. Alternatively or in addition, the blockchainnetwork 100 may be a permissioned blockchain using an endorsing and/orordering node for committing blocks to the blockchain. A particular formof a permissioned blockchain network 100 will be described in furtherdetail below.

FIG. 2A illustrates a blockchain architecture configuration 200,according to example embodiments. Referring to FIG. 2A, the blockchainarchitecture 200 may include certain blockchain elements, for example, agroup of blockchain nodes 202. The blockchain nodes 202 may include oneor more nodes 204-210 (these four nodes are depicted by example only).These nodes participate in a number of activities, such as blockchaintransaction addition and validation process (consensus). One or more ofthe blockchain nodes 204-210 may endorse transactions based onendorsement policy and may provide an ordering service for allblockchain nodes in the architecture 200. A blockchain node may initiatea blockchain authentication and seek to write to a blockchain immutableledger stored in blockchain layer 216, a copy of which may also bestored on the underpinning physical infrastructure 214. The blockchainconfiguration may include one or more applications 224 which are linkedto application programming interfaces (APIs) 222 to access and executestored program/application code 220 (e.g., chaincode, smart contracts,etc.) which can be created according to a customized configurationsought by participants and can maintain their own state, control theirown assets, and receive external information. This can be deployed as atransaction and installed, via appending to the distributed ledger, onall blockchain nodes 204-210.

The blockchain base or platform 212 may include various layers ofblockchain data, services (e.g., cryptographic trust services, virtualexecution environment, etc.), and underpinning physical computerinfrastructure that may be used to receive and store new transactionsand provide access to auditors which are seeking to access data entries.The blockchain layer 216 may expose an interface that provides access tothe virtual execution environment necessary to process the program codeand engage the physical infrastructure 214. Cryptographic trust services218 may be used to verify transactions such as asset exchangetransactions and keep information private.

The blockchain architecture configuration of FIG. 2A may process andexecute program/application code 220 via one or more interfaces exposed,and services provided, by blockchain platform 212. The code 220 maycontrol blockchain assets. For example, the code 220 can store andtransfer data, and may be executed by nodes 204-210 in the form of asmart contract and associated chaincode with conditions or other codeelements subject to its execution. As a non-limiting example, smartcontracts may be created to execute reminders, updates, and/or othernotifications subject to the changes, updates, etc. The smart contractscan themselves be used to identify rules associated with authorizationand access requirements and usage of the ledger. For example, theinformation 226, such as transaction requests, may be processed by oneor more processing entities (e.g., virtual machines) included in theblockchain layer 216. The result 228 may include the outcome of thetransaction request, e.g. a complete transaction. The physicalinfrastructure 214 may be utilized to retrieve any of the data orinformation described herein.

Within chaincode, a smart contract may be created via a high-levelapplication and programming language, and then written to a block in theblockchain. The smart contract may include executable code which isregistered, stored, and/or replicated with a blockchain (e.g.,distributed network of blockchain peers). A transaction is an executionof the smart contract code which can be performed in response toconditions associated with the smart contract being satisfied. Theexecuting of the smart contract may trigger a trusted modification(s) toa state of a digital blockchain ledger. The modification(s) to theblockchain ledger caused by the smart contract execution may beautomatically replicated throughout the distributed network ofblockchain peers through one or more consensus protocols.

The smart contract may write data to the blockchain in the format ofkey-value pairs. Furthermore, the smart contract code can read thevalues stored in a blockchain and use them in application operations.The smart contract code can write the output of various logic operationsinto the blockchain. The code may be used to create a temporary datastructure in a virtual machine or other computing platform. Data writtento the blockchain can be public and/or can be encrypted and maintainedas private. The temporary data that is used/generated by the smartcontract is held in memory by the supplied execution environment, thendeleted once the data needed for the blockchain is identified.

A chaincode may include the code interpretation of a smart contract,with additional features. As described herein, the chaincode may beprogram code deployed on a computing network, where it is executed andvalidated by chain validators together during a consensus process. Thechaincode receives a hash and retrieves from the blockchain a hashassociated with the data template created by use of a previously storedfeature extractor. If the hashes of the hash identifier and the hashcreated from the stored identifier template data match, then thechaincode sends an authorization key to the requested service. Thechaincode may write to the blockchain data associated with thecryptographic details. In FIG. 2A, a peer node may process a transactionrequest 226. One function may be to process the transaction request toproduce a transaction result, which may be provided to one or more ofthe nodes 204-210.

FIG. 2B illustrates an example of a transactional flow 250 between nodesof the blockchain in accordance with an example embodiment. Referring toFIG. 2B, the transaction flow may include a transaction proposal 291sent by an application client node 260 to an endorsing peer node 281.The endorsing peer 281 may verify the client signature and execute achaincode function to initiate the transaction. The output may includethe chaincode results, a set of key/value versions that were read in thechaincode (read set), and the set of keys/values that were written inchaincode (write set). The proposal response 292 is sent back to theclient 260 along with an endorsement signature, if approved. The client260 assembles the endorsements into a transaction payload 293 andbroadcasts it to an ordering service node 284. The ordering service node284 then delivers ordered transactions as blocks to all peers 281-283 ona channel. Before committal to the blockchain, each peer 281-283 mayvalidate the transaction. For example, the peers may check theendorsement policy to ensure that the correct allotment of the specifiedpeers have signed the results and authenticated the signatures againstthe transaction payload 293.

Referring again to FIG. 2B, the client node 260 initiates thetransaction 291 by constructing and sending a request to the peer node281, which is an endorser. The client 260 may include an applicationleveraging a supported software development kit (SDK), such as NODE,JAVA, PYTHON, and the like, which utilizes an available API to generatea transaction proposal. The proposal is a request to invoke a chaincodefunction so that data can be read and/or written to the ledger (i.e.,write new key value pairs for the assets). The SDK may serve as a shimto package the transaction proposal into a properly architected format(e.g., protocol buffer over a remote procedure call (RPC)) and take theclient's cryptographic credentials to produce a unique signature for thetransaction proposal.

In response, the endorsing peer node 281 may verify (a) that thetransaction proposal is well formed, (b) the transaction has not beensubmitted already in the past (replay-attack protection), (c) thesignature is valid, and (d) that the submitter (client 260, in theexample) is properly authorized to perform the proposed operation onthat channel. The endorsing peer node 281 may take the transactionproposal inputs as arguments to the invoked chaincode function. Thechaincode is then executed against a current state database to producetransaction results including a response value, read set, and write set.However, no updates are made to the ledger at this point. In 292, theset of values, along with the endorsing peer node's 281 signature ispassed back as a proposal response 292 to the SDK of the client 260which parses the payload for the application to consume.

In response, the application of the client 260 inspects/verifies theendorsing peers' signatures and compares the proposal responses todetermine if the proposal response is the same. If the chaincode onlyqueried the ledger, the application would inspect the query response andwould typically not submit the transaction to the ordering node service284. If the client application intends to submit the transaction to theordering node service 284 to update the ledger, the applicationdetermines if the specified endorsement policy has been fulfilled beforesubmitting (i.e., did all peer nodes necessary for the transactionendorse the transaction). Here, the client may include only one ofmultiple parties to the transaction. In this case, each client may havetheir own endorsing node, and each endorsing node will need to endorsethe transaction. The architecture is such that even if an applicationselects not to inspect responses or otherwise forwards an unendorsedtransaction, the endorsement policy will still be enforced by peers andupheld at the commit validation phase.

After successful inspection, in step 293 the client 260 assemblesendorsements into a transaction and broadcasts the transaction proposaland response within a transaction message to the ordering node 284. Thetransaction may contain the read/write sets, the endorsing peers'signatures and a channel ID. The ordering node 284 does not need toinspect the entire content of a transaction in order to perform itsoperation, instead the ordering node 284 may simply receive transactionsfrom all channels in the network, order them chronologically by channel,and create blocks of transactions per channel.

The blocks of the transaction are delivered from the ordering node 284to all peer nodes 281-283 on the channel. The transactions 294 withinthe block are validated to ensure any endorsement policy is fulfilledand to ensure that there have been no changes to ledger state for readset variables since the read set was generated by the transactionexecution. Transactions in the block are tagged as being valid orinvalid. Furthermore, in step 295 each peer node 281-283 appends theblock to the channel's chain, and for each valid transaction the writesets are committed to current state database. An event is emitted, tonotify the client application that the transaction (invocation) has beenimmutably appended to the chain, as well as to notify whether thetransaction was validated or invalidated.

FIG. 3 illustrates an example of a permissioned blockchain network 300,which features a distributed, decentralized peer-to-peer architecture,and a certificate authority 318 managing user roles and permissions. Inthis example, the blockchain user 302 may submit a transaction to thepermissioned blockchain network 310. In this example, the transactioncan be a deploy, invoke or query, and may be issued through aclient-side application leveraging an SDK, directly through a REST API,or the like. Trusted business networks may provide access to regulatorsystems 314, such as auditors (the Securities and Exchange Commission ina U.S. equities market, for example). Meanwhile, a blockchain networkoperator system of nodes 308 manage member permissions, such asenrolling the regulator system 310 as an “auditor” and the blockchainuser 302 as a “client.” An auditor could be restricted only to queryingthe ledger whereas a client could be authorized to deploy, invoke, andquery certain types of chaincode.

A blockchain developer system 316 writes chaincode and client-sideapplications. The blockchain developer system 316 can deploy chaincodedirectly to the network through a REST interface. To include credentialsfrom a traditional data source 330 in chaincode, the developer system316 could use an out-of-band connection to access the data. In thisexample, the blockchain user 302 connects to the network through a peernode 312. Before proceeding with any transactions, the peer node 312retrieves the user's enrollment and transaction certificates from thecertificate authority 318. In some cases, blockchain users must possessthese digital certificates in order to transact on the permissionedblockchain network 310. Meanwhile, a user attempting to drive chaincodemay be required to verify their credentials on the traditional datasource 330. To confirm the user's authorization, chaincode can use anout-of-band connection to this data through a traditional processingplatform 320.

FIG. 4 illustrates a system messaging diagram for performing a consensuscheckpoint method, according to example embodiments. Referring to FIG.4, the system diagram 400 includes three peer nodes 410, 430, 440 thateach maintain copy of the blockchain and the state database. While threepeer nodes are shown, the blockchain network may contain any number ofpeer nodes. Each node executes a thread/subprocess for performing aconsensus checkpoint procedure. In one embodiment, the chaincodespecifies that a checkpoint should be created every ‘m’ blocks committedto the blockchain. The chaincode may run in the background of the nodeuntil the current block number of the blockchain matches the nextcheckpoint interval 412. The checkpoint procedure is then invoked 414and the node generates a checkpoint state. In one embodiment, thecheckpoint state is created as a merkle tree. The node 410 broadcaststhe root hash of the merkle tree 416 to the other peer nodes 430, 440 ofthe network and similarly receives the root hash 418 generated by thesame checkpoint procedure running on those nodes. The node 410 applies aconsensus requirement to determine if there is consensus regarding thenode's checkpoint state 420. In one embodiment, consensus may bedetermined if the peer receives the same root hash from a majority ofpeers. If consensus is achieved, then the merkle tree is stored as acheckpoint in the node 422. If the node does not detect consensus, thenthe node may seek to resolve the lack of consensus as will be describedin more detail below.

FIG. 5A illustrates a flow diagram 500 of an example method forconsensus checkpointing of a world state in a blockchain, according toexample embodiments. With reference to FIG. 5A, at step 502, acheckpoint trigger is activated. The checkpoint trigger may be a blockcounter that detects that an interval number of blocks have beencommitted to the blockchain. For example, the checkpoint trigger mayactivate every “m” blocks. In one embodiment, the checkpoint trigger mayactivate every 1000 blocks, though any value of “m” may be chosen. Thevalue of “m” may be dependent on various factors including, withoutlimitation, the frequency or rate at which new blocks are created, thetypical number of transactions recorded per block, the size of the stateledger, etc. The checkpoint trigger may be a component executing locallywithin each peer node, or may be a central trigger, e.g. executed by anendorsing node or ordering node of the blockchain network thatbroadcasts a checkpoint trigger signal to each peer node.

Once the checkpoint trigger is activated, each peer node generates arepresentation of the current state of the database 504. In oneembodiment, each node generates a merkle tree representation of thecurrent state with the key/value pairs in the leaf nodes of the merkletree. The process and schema for generating the merkle tree may beestablished by policy and executed by a dedicated thread/sub-process toensure that each node generates the merkle tree by the same process. Atstep 506, nodes undertake a consensus process for the checkpoint state.In the merkle tree example, it is not necessary to submit the entirerepresentation for consensus. Instead, it may be sufficient for just theroot hash of the merkle tree to be submitted.

To perform consensus, each node broadcasts its root hash of the merkletree to each other peer node. A peer node receives the root hashes ofits peers and compares each received root hash to the peer's owngenerated root hash. Any consensus algorithm may be utilized including,without limitation, Raft, PBFT, Paxos, Voting, etc. If consensus on thecurrent state is reached, the peer node may store the current state as acheckpoint 508. Consensus may be determined based on a policy. In oneembodiment, consensus may be determined if the peer receives the sameroot hash from a majority of peers. The person skilled in the art willreadily understand that more or less stringent consensus requirementsmay be set.

The merkle tree may be generated using several methods. In oneembodiment, a fresh hash computation is performed at each checkpointinterval. When the checkpoint time is reached, a range query is used toretrieve all key value pairs from the database. A set of key/value pairsis allocated to each leaf node. Rules and policies may be set todetermine the number of key/value pairs allocated to each data bucket ofthe leaf node. Once the data bucket of a leaf node is fully allocatedwith its set of key/value pairs, the merkle tree hash computation cancommence, without waiting to retrieve and allocate all entries from thedatabase to all of the leaf nodes.

The whole merkle tree (including leaf nodes which contains key/valuepairs) can be dumped to a separate storage unit as a backup(checkpoint). Only the recent merkle tree need be stored in the peer.

Performing a fresh and complete hash of the state database at eachcheckpoint provides a simple implementation of a checkpoint method andis efficient when the checkpoint interval “m” is large, e.g. every 1million blocks, and/or when the key/value pair modification rate ishigh. However, because there is no reuse of past computation, there canbe a sudden load on the state database, though work stealing can be usedto avoid this sudden surge in resource utilization.

In a work stealing approach:G=(next checkpoint block number)−(current checkpoint block number);

M—Denotes the number of entries in the state DB.

After every block commit, p*(M/(0.9*G)) entries are fetched from thedatabase to construct the merkle tree. The value of p (>=1) is dependenton the available CPU and disk bandwidth (which can be identified byfetching these details periodically from the operating system).

FIG. 5B shows a merkle tree 510 produced using the fresh hashingprotocol. As shown in FIG. 5B, the merkle tree leaf nodes 516 provideddata buckets 518 that are filled sequentially with key/value pairs untilthe memory allocation of a leaf node is full. The final leaf node in thetree may have spare data resource. The level nodes 514 contain aconcatenation hash of the child nodes, and this may extend throughmultiple levels to the root node 512 which contains the root hash.

Because the checkpoint process may occur concurrently with the normaloperation of blockchain network, new blocks may be committed to theblockchain and the StateDB may change while the checkpoint process isoccurring. To ensure that the correct state of key/value pairs, i.e. thestate existing at the checkpoint block number, is used to generate thecheckpoint merkle tree, backup of old values of key/value pairs shouldbe taken in any future block commits from the checkpoint block number upuntil the checkpoint has been created. Thus, when the checkpoint processretrieves a key/value pair from the StateDB, if version(key)>thecheckpoint block height, the key/value pair is retrieved from backup.For deletes of state during a block commit while the checkpoint is beinggenerated, the state (key/value pair) should not be actually deletedfrom the database or else range queries would not return that state andthe checkpoint would not falsely omit that key/value pair from thecheckpoint merkle tree. Instead, separate bookkeeping of delete statesis undertaken so that these states persist in the StateDB and subsequenttransactions to read/modify these states are prevented. However, therange query used for the checkpoint should be able to read and retrievethese states. Once the checkpoint hash computation is done, the stateswhich are bookmarked as deleted from the StateDB can be actually deletedfrom the StateDB.

An alternative checkpoint method relies on incrementally computing themerkle tree with an accompanying index. As shown in FIG. 5C, the leafnode 526 of the merkle tree 520 is a data bucket 528 that contains afixed number of key/value pair slots. For example, a leaf node 526 maybe configured to accommodate 100 key/value pairs, though a bucket may beof any appropriate size as will be readily determined by the personskilled in the art. To accompany the merkle tree 520, two additionaldata structures may be required. There may be a Bitmap index or a freelist 527 to denote the next free slot in the merkle tree and ahierarchical index 529 to keep the key as index-key and pointer to theleaf node/slot. The level nodes 524 contain a concatenation hash of thechild nodes, and this may extend through multiple levels to the rootnode 522 which contains the root hash.

The merkle tree may be constructed using four operations as follows.

Insert (Key, Value)

Find the first free slot in the leaf nodes and insert the key/value inthe free slot and mark the bucket as dirty (i.e. modified).

Delete (Key)

Delete the key/value pair from the leaf node and add the slot to thefree list. Mark the bucket as dirty.

Update (Key, Value)

Update the key/value pair in the leaf node and mark the bucket as dirty

RecomputeHash( ) or FinalizeHash( )

Depending upon the dirtied leaf nodes (a.k.a bucket), recompute themerkle root hash.

After every ‘c’ blocks within a checkpoint interval ‘m’, all valid writesets from last ‘c’ blocks are taken to form a partially ordered set.From the partially ordered set, the maximal elements are chosen to forma final write set. For example, if the same key is modified in block 5and block 6, only the key/value pair in block 6 would be considered.

The value “c” is decided dynamically based on the number of key/valuepairs in the final write set and available CPU resource & disk bandwidth

For each key/value pair in the final write set (combining last ‘c’blocks), one of the three merkle tree modification operations describedabove would be performed. That is, for each key/value pair in the finalwrite set, the system would perform:

Delete operation on the merkle tree & update the index;

Update operation on the merkle tree (if the index lookup succeed);

Insert operation on the merkle tree (if the index lookup fails) & updatethe index.

Once all of the key/value pairs in the final write set have beenprocessed, the merkle root hash is computed depending upon the dirtiedbuckets or leaf nodes. These processes can be performed just beforereaching the checkpointing interval.

For this method, the expected load on the state database is less whencompared to fresh computation of the hash at each checkpoint interval.In addition, checkpointing latency, i.e. the time taken to complete thecheckpointing consensus/process, may be less. This method isparticularly suitable when the checkpoint interval is very small thoughthe method has additional complexity compared to fresh computation ofthe merkle tree, including the requirement to maintain the index.

A further alternative checkpointing method uses hash function basedincremental hash computation every “c” blocks within the checkpointinterval “m”. As shown in FIG. 5D, in this approach, there are aninitial “p” buckets 538 each forming a leaf node 536 of the merkle tree530. Each bucket or leaf node can hold any number of key/value pairs andthus the number “p” remains fixed until such time as the merkle treecomputation becomes inefficient. For a given key/value pair, a hashfunction would be used to decide the destination bucket.

There are four operations used to construct the merkle tree as follows:

Insert (Key/Value)

Hash(key) determines the bucket or leaf node in the merkle tree. Giventhat the key does not exist already in the leaf node, an insert ofkey/value is executed and the leaf node is marked as dirty (modified).

Delete (Key)

Hash(key) determines the bucket or leaf node in the merkle tree. Linearor binary search to find the key and delete the key from the leaf node.Mark the leaf node as dirty.

Update (Key/Value)

Hash(key) determines to a bucket or a leaf node in the merkle tree.Linear or binary search to find key and update the key/value pair in theleaf node. Mark the leaf node as dirty.

RecomputeHash or FinalizeHash

Depending upon the dirtied leaf node(s), recompute the merkle root hash.

The blockchain network may implement a consistent way across peers toidentify that the current p buckets/leaf-nodes are inefficient for thenumber of states or key/value pairs. Consensus would be required toincrease the number of buckets or leaf nodes. Once the majority of thenodes agree, a new merkle tree would be created with a higher number ofbuckets. Rehashing by doing a range query on the state database (asdescribed for the fresh hash computation) could then produce the newmerkle tree.

This method has advantage over the previous incremental method in thatindex management is not required because the leaf node is determined bya hash of the unique key. Thus, there is a lesser number of lookupoperations required during search for update/delete operations. However,rehashing or restructuring of the merkle tree may be required when thebucket size is unbalanced (costlier) and there is a cost associated withthe hash function.

The use of checkpoints for the state database allow certain efficienciesto be achieved and additional operations to be performed.

The checkpoint state of the database can make node bootstrapping of newnodes more efficient by reducing the bootstrapping duration. FIG. 5Ecomponent diagram 540 shows three instantiated peers, Peer0 542, Peer1544, Peer2 546, that each operate a state database 548 at the currentblock height ‘n’ and block storage 550 also at height ‘n’. As will bedescribed in more detail below, the block storage may comprise archivedblock storage of old blocks and fast access storage of more recentlycommitted blocks up to the current block “n”. Owing to differences incomputing power between nodes and the speed at which nodes can commitblocks to the blockchain, at any given point in time there can be smalldifferences in the specific height “n” between nodes.

Each instantiated peer also stores a consensus Merkle treerepresentation 552 of the stateDB at block height h, being the blockheight at the last checkpoint interval. Typically, ‘h’ will be anintegral multiple of ‘m’, the checkpoint interval. When a new nodejoins, e.g. Peer3 560, rather than executing all of the transactions onthe blockchain to create the current state, the new node can obtain themerkle tree representation of the state of database at the lastcheckpoint interval from a peer node 562 together with a set of proofs,e.g. the consensus hash, to verify that the shared state is not tamperedwith. Specifically, the receiving node can verify the proof byrebuilding the merkle root hash using the leaves of the received merkletree and then checking whether the constructed root hash matches withthe root hash in the consensus. If there is a match, then the state isnot tampered with. If there is a mismatch the hashes in the level nodescan be checked to identity which bucket or leaf node is tampered with.Then, the node can retrieve that particular bucket from other nodes.This process is described in more detail below with reference to FIG.5H.

Because the merkle tree representation includes each key/value pair ofthe state DB in the leaf nodes of the merkle tree, the new peer 560 cangenerate the state DB by copying each of these key/value pairs to thepeer's own database as an initial state database 566. The peer can thenfetch the blocks of the blockchain since the last checkpoint 568, i.e.where Blocknum>h, and run only the transactions of these blocks on thestate DB to produce the final current state of the DB. Confirmation thatthe new peer has established correctly can be undertaken firstly byverifying that the root hash of the checkpoint state of the stateDBmatches the consensus root hash, and then at the next checkpointinterval when the peer will generate its own merkle tree on its owncurrent state and submit for consensus. The peer can instantiate theblockchain by retrieving the blocks of the blockchain from block 1 up tothe current block, or alternatively up to the last checkpoint, out ofband if required. These blocks may be stored in archive storage as willbe described in more detail below.

The checkpoint allows more efficient use of disk space. As shown incomponent diagram 569 in FIG. 5F, each peer node stores the StateDB atthe current block height and a checkpoint of StateDB at the lastcheckpoint height ‘h’. Typically, ‘h’ will be an integral multiple ofthe checkpoint interval ‘m’. Each peer node further stores the blockstorage at height ‘n’. A peer node may include various types of datastorage, including hard disk drive (HDD) and solid-state drives (SSD).Typically, a peer might store the blockchain on SSD allowing for data tobe quickly accessed, fast read/write, etc. However, for largeblockchains, full storage on SSD may become expensive. After a statecheckpoint, nodes can remove blocks from the block storage to free upthe storage. The node may remove/purge/prune the blocks or archiveblocks to a slow storage to conserve space. As shown in FIG. 5F, eachpeer includes the blocks up to the last checkpoint interval m (i.e.blocks 0 . . . m) 570 and blocks since the last checkpoint, m+1, m+2etc. 572. Blocks 0 to m can be moved to alternative disk storage, whichmay, for example, allow a smaller SSD storage to be deployed at thenode.

The checkpoint may be used to quickly recover from a diskcorruption/fork and to perform a Point-in-Block recovery. As shown incomponent diagram 579 in FIG. 5G, after every checkpoint, the wholeMerkle tree (including the data in leaf nodes) can be stored as abackup. Thus, each peer may store checkpoints at successive checkpointintervals, e.g. checkpoint m 580, checkpoint 2 m 582, checkpoint 3 m584, etc. and associating consensus data for each of these checkpoints,586, 588, 590. Using the old Merkle tree stored in a backup, a peer cango back in time, recover from disk corruption and fork.

Point-in-Block recovery may also be used to correct from a mistake orrecover from an attack. For example, in a network consisting of banks,say the block 100 had a transaction which was submitted mistakenly orwas an attack by a hacker. At that time, banks may not identify theattack. Later, when the banks come to find the attack, bank expects someof the transactions which were submitted after block 100 to be executedon the wrong data. Instead of finding which transactions to be reverted(which might be very difficult), all banks in the network can agree togo back in time to a checkpoint which was created before block 100(using the merkle tree state dump) and invalidate the transactionsubmitted by the attacker. Then, the blockchain network can revalidatetransactions that was submitted after the 100th block.

As described above, consensus on the root hash of the merkle tree may berequired in order for the merkle tree to be established as a checkpoint.If, for any peer, the peer's root hash differs from the consensus roothash, a comparison between the peer's merkle tree and the consensusmerkle tree may be used to locate the source of the discrepancy. Asshown component diagram 589 in FIG. 5H, the hashes of each level node592 can be compared to identify the branch, and ultimately the leafnodes 594, where the hash mismatch occurs. The peer may correct thestate by restoring the merkle tree at the previous checkpoint,retrieving the blocks since the previous checkpoint from a non-corruptedor forked node, and re-executing the transactions of the blocks torestore the current state.

An advantage of the present embodiments described herein includes thatthe checkpoint method is significantly agnostic with regard to statedatabases, machine architectures, file system types, etc. Thecheckpointing methods provide an efficient computation of the CurrentState Hash for checkpointing (every ‘m’ blocks) and generation of tamperproof State dump in a single meta-operation.

FIG. 6A illustrates an example system 600 that includes a physicalinfrastructure 610 configured to perform various operations according toexample embodiments. Referring to FIG. 6A, the physical infrastructure610 includes a module 612 and a module 614. The module 614 includes ablockchain 620 and a smart contract 630 (which may reside on theblockchain 620), that may execute any of the operational steps 608 (inmodule 612) included in any of the example embodiments. Thesteps/operations 608 may include one or more of the embodimentsdescribed or depicted and may represent output or written informationthat is written or read from one or more smart contracts 630 and/orblockchains 620. The physical infrastructure 610, the module 612, andthe module 614 may include one or more computers, servers, processors,memories, and/or wireless communication devices. Further, the module 612and the module 614 may be a same module.

FIG. 6B illustrates an example system 640 configured to perform variousoperations according to example embodiments. Referring to FIG. 6B, thesystem 640 includes a module 612 and a module 614. The module 614includes a blockchain 620 and a smart contract 630 (which may reside onthe blockchain 620), that may execute any of the operational steps 608(in module 612) included in any of the example embodiments. Thesteps/operations 608 may include one or more of the embodimentsdescribed or depicted and may represent output or written informationthat is written or read from one or more smart contracts 630 and/orblockchains 620. The physical infrastructure 610, the module 612, andthe module 614 may include one or more computers, servers, processors,memories, and/or wireless communication devices. Further, the module 612and the module 614 may be a same module.

FIG. 6C illustrates an example smart contract configuration amongcontracting parties and a mediating server configured to enforce thesmart contract terms on the blockchain according to example embodiments.Referring to FIG. 6C, the configuration 650 may represent acommunication session, an asset transfer session or a process orprocedure that is driven by a smart contract 630 which explicitlyidentifies one or more user devices 652 and/or 656. The execution,operations and results of the smart contract execution may be managed bya server 654. Content of the smart contract 630 may require digitalsignatures by one or more of the entities 652 and 656 which are partiesto the smart contract transaction. The results of the smart contractexecution may be written to a blockchain 620 as a blockchaintransaction. The smart contract 630 resides on the blockchain 620 whichmay reside on one or more computers, servers, processors, memories,and/or wireless communication devices.

FIG. 6D illustrates a common interface 660 for accessing logic and dataof a blockchain, according to example embodiments. Referring to theexample of FIG. 6D, an application programming interface (API) gateway662 provides a common interface for accessing blockchain logic (e.g.,smart contract 630 or other chaincode) and data (e.g., distributedledger, etc.) In this example, the API gateway 662 is a common interfacefor performing transactions (invoke, queries, etc.) on the blockchain byconnecting one or more entities 652 and 656 to a blockchain peer (i.e.,server 654). Here, the server 654 is a blockchain network peer componentthat holds a copy of the world state and a distributed ledger allowingclients 652 and 656 to query data on the world state as well as submittransactions into the blockchain network where, depending on the smartcontract 630 and endorsement policy, endorsing peers will run the smartcontracts 630.

The above embodiments may be implemented in hardware, in a computerprogram executed by a processor, in firmware, or in a combination of theabove. A computer program may be embodied on a computer readable medium,such as a storage medium. For example, a computer program may reside inrandom access memory (“RAM”), flash memory, read-only memory (“ROM”),erasable programmable read-only memory (“EPROM”), electrically erasableprogrammable read-only memory (“EEPROM”), registers, hard disk, aremovable disk, a compact disk read-only memory (“CD-ROM”), or any otherform of storage medium known in the art.

An exemplary storage medium may be coupled to the processor such thatthe processor may read information from, and write information to, thestorage medium. In the alternative, the storage medium may be integralto the processor. The processor and the storage medium may reside in anapplication specific integrated circuit (“ASIC”). In the alternative,the processor and the storage medium may reside as discrete components.

FIG. 7A illustrates a process 700 of a new block being added to adistributed ledger 730, according to example embodiments, and FIG. 7Billustrates contents of a block structure 750 for blockchain, accordingto example embodiments. Referring to FIG. 7A, clients (not shown) maysubmit transactions to blockchain nodes 721, 722, and/or 723. Clientsmay be instructions received from any source to enact activity on theblockchain 730. As an example, clients may be applications that act onbehalf of a requester, such as a device, person or entity to proposetransactions for the blockchain. The plurality of blockchain peers(e.g., blockchain nodes 721, 722, and 723) may maintain a state of theblockchain network and a copy of the distributed ledger 730. Differenttypes of blockchain nodes/peers may be present in the blockchain networkincluding endorsing peers which simulate and endorse transactionsproposed by clients and committing peers which verify endorsements,validate transactions, and commit transactions to the distributed ledger730. In this example, the blockchain nodes 721, 722, and 723 may performthe role of endorser node, committer node, or both.

The distributed ledger 730 includes a blockchain 732 which storesimmutable, sequenced records in blocks, and a state database 734(current world state) maintaining a current state of the blockchain 732.One distributed ledger 730 may exist per channel and each peer maintainsits own copy of the distributed ledger 730 for each channel of whichthey are a member. The blockchain 732 is a transaction log, structuredas hash-linked blocks where each block contains a sequence of Ntransactions. Blocks may include various components such as shown inFIG. 7B. The linking of the blocks (shown by arrows in FIG. 7A) may begenerated by adding a hash of a prior block's header within a blockheader of a current block. In this way, all transactions on theblockchain 732 are sequenced and cryptographically linked togetherpreventing tampering with blockchain data without breaking the hashlinks. Furthermore, because of the links, the latest block in theblockchain 732 represents every transaction that has come before it. Theblockchain 732 may be stored on a peer file system (local or attachedstorage), which supports an append-only blockchain workload.

The current state of the blockchain 732 and the distributed ledger 732may be stored in the state database 734. Here, the current state datarepresents the latest values for all keys ever included in the chaintransaction log of the blockchain 732. Chaincode invocations executetransactions against the current state in the state database 734. Tomake these chaincode interactions extremely efficient, the latest valuesof all keys are stored in the state database 734. The state database 734may include an indexed view into the transaction log of the blockchain732, it can therefore be regenerated from the chain at any time. Thestate database 734 may automatically get recovered (or generated ifneeded) upon peer startup, before transactions are accepted.

Endorsing nodes receive transactions from clients and endorse thetransaction based on simulated results. Endorsing nodes hold smartcontracts which simulate the transaction proposals. When an endorsingnode endorses a transaction, the endorsing nodes creates a transactionendorsement which is a signed response from the endorsing node to theclient application indicating the endorsement of the simulatedtransaction. The method of endorsing a transaction depends on anendorsement policy which may be specified within chaincode. An exampleof an endorsement policy is “the majority of endorsing peers mustendorse the transaction.” Different channels may have differentendorsement policies. Endorsed transactions are forward by the clientapplication to ordering service 710.

The ordering service 710 accepts endorsed transactions, orders them intoa block, and delivers the blocks to the committing peers. For example,the ordering service 710 may initiate a new block when a threshold oftransactions has been reached, a timer times out, or another condition.In the example of FIG. 7A, blockchain node 722 is a committing peer thathas received a new data block 750 for storage on blockchain 730.

The ordering service 710 may be made up of a cluster of orderers. Theordering service 710 does not process transactions, smart contracts, ormaintain the shared ledger. Rather, the ordering service 710 may acceptthe endorsed transactions and specifies the order in which thosetransactions are committed to the distributed ledger 730. Thearchitecture of the blockchain network may be designed such that thespecific implementation of ‘ordering’ (e.g., Solo, Kafka, BFT, etc.)becomes a pluggable component.

Transactions are written to the distributed ledger 730 in a consistentorder. The order of transactions is established to ensure that theupdates to the state database 734 are valid when they are committed tothe network. Unlike a cryptocurrency blockchain system (e.g., Bitcoin,etc.) where ordering occurs through the solving of a cryptographicpuzzle, or mining, in this example the parties of the distributed ledger730 may choose the ordering mechanism that best suits that network.

When the ordering service 710 initializes a new block 750, the new block750 may be broadcast to committing peers (e.g., blockchain nodes 721,722, and 723). In response, each committing peer validates thetransaction within the new block 750 by checking to make sure that theread set and the write set still match the current world state in thestate database 734. Specifically, the committing peer can determinewhether the read data that existed when the endorsers simulated thetransaction is identical to the current world state in the statedatabase 734. When the committing peer validates the transaction, thetransaction is written to the blockchain 732 on the distributed ledger730, and the state database 734 is updated with the write data from theread-write set. If a transaction fails, that is, if the committing peerfinds that the read-write set does not match the current world state inthe state database 734, the transaction ordered into a block will stillbe included in that block, but it will be marked as invalid, and thestate database 734 will not be updated.

Referring to FIG. 7B, a block 750 (also referred to as a data block)that is stored on the blockchain 732 of the distributed ledger 730 mayinclude multiple data segments such as a block header 760, block data770, and block metadata 780. It should be appreciated that the variousdepicted blocks and their contents, such as block 750 and its contents.shown in FIG. 7B are merely for purposes of example and are not meant tolimit the scope of the example embodiments. In some cases, both theblock header 760 and the block metadata 780 may be smaller than theblock data 770 which stores transaction data, however this is not arequirement. The block 750 may store transactional information of Ntransactions (e.g., 100, 500, 1000, 2000, 3000, etc.) within the blockdata 770. The block 750 may also include a link to a previous block(e.g., on the blockchain 732 in FIG. 7A) within the block header 760. Inparticular, the block header 760 may include a hash of a previousblock's header. The block header 760 may also include a unique blocknumber, a hash of the block data 770 of the current block 750, and thelike. The block number of the block 750 may be unique and assigned in anincremental/sequential order starting from zero. The first block in theblockchain may be referred to as a genesis block which includesinformation about the blockchain, its members, the data stored therein,etc.

The block data 770 may store transactional information of eachtransaction that is recorded within the block 750. For example, thetransaction data may include one or more of a type of the transaction, aversion, a timestamp, a channel ID of the distributed ledger 730, atransaction ID, an epoch, a payload visibility, a chaincode path (deploytx), a chaincode name, a chaincode version, input (chaincode andfunctions), a client (creator) identify such as a public key andcertificate, a signature of the client, identities of endorsers,endorser signatures, a proposal hash, chaincode events, response status,namespace, a read set (list of key and version read by the transaction,etc.), a write set (list of key and value, etc.), a start key, an endkey, a list of keys, a Merkle tree query summary, and the like. Thetransaction data may be stored for each of the N transactions.

In some embodiments, the block data 770 may also store data 772 whichadds additional information to the hash-linked chain of blocks in theblockchain 732. Accordingly, the data 772 can be stored in an immutablelog of blocks on the distributed ledger 730. Some of the benefits ofstoring such data 772 are reflected in the various embodiments disclosedand depicted herein.

The block metadata 780 may store multiple fields of metadata (e.g., as abyte array, etc.). Metadata fields may include signature on blockcreation, a reference to a last configuration block, a transactionfilter identifying valid and invalid transactions within the block, lastoffset persisted of an ordering service that ordered the block, and thelike. The signature, the last configuration block, and the orderermetadata may be added by the ordering service 710. Meanwhile, acommitter of the block (such as blockchain node 722) may addvalidity/invalidity information based on an endorsement policy,verification of read/write sets, and the like. The transaction filtermay include a byte array of a size equal to the number of transactionsin the block data 770 and a validation code identifying whether atransaction was valid/invalid.

FIG. 8 is not intended to suggest any limitation as to the scope of useor functionality of embodiments of the application described herein.Regardless, the computing node 800 is capable of being implementedand/or performing any of the functionality set forth hereinabove.

In computing node 800 there is a computer system/server 802, which isoperational with numerous other general purpose or special purposecomputing system environments or configurations. Examples of well-knowncomputing systems, environments, and/or configurations that may besuitable for use with computer system/server 802 include, but are notlimited to, personal computer systems, server computer systems, thinclients, thick clients, hand-held or laptop devices, multiprocessorsystems, microprocessor-based systems, set top boxes, programmableconsumer electronics, network PCs, minicomputer systems, mainframecomputer systems, and distributed cloud computing environments thatinclude any of the above systems or devices, and the like.

Computer system/server 802 may be described in the general context ofcomputer system-executable instructions, such as program modules, beingexecuted by a computer system. Generally, program modules may includeroutines, programs, objects, components, logic, data structures, and soon that perform particular tasks or implement particular abstract datatypes. Computer system/server 802 may be practiced in distributed cloudcomputing environments where tasks are performed by remote processingdevices that are linked through a communications network. In adistributed cloud computing environment, program modules may be locatedin both local and remote computer system storage media including memorystorage devices.

As shown in FIG. 8, computer system/server 802 in cloud computing node800 is shown in the form of a general-purpose computing device. Thecomponents of computer system/server 802 may include, but are notlimited to, one or more processors or processing units 804, a systemmemory 806, and a bus that couples various system components includingsystem memory 806 to processor 804.

The bus represents one or more of any of several types of busstructures, including a memory bus or memory controller, a peripheralbus, an accelerated graphics port, and a processor or local bus usingany of a variety of bus architectures. By way of example, and notlimitation, such architectures include Industry Standard Architecture(ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA)bus, Video Electronics Standards Association (VESA) local bus, andPeripheral Component Interconnects (PCI) bus.

Computer system/server 802 typically includes a variety of computersystem readable media. Such media may be any available media that isaccessible by computer system/server 802, and it includes both volatileand non-volatile media, removable and non-removable media. System memory806, in one embodiment, implements the flow diagrams of the otherfigures. The system memory 806 can include computer system readablemedia in the form of volatile memory, such as random-access memory (RAM)810 and/or cache memory 812. Computer system/server 802 may furtherinclude other removable/non-removable, volatile/non-volatile computersystem storage media. By way of example only, storage system 814 can beprovided for reading from and writing to a non-removable, non-volatilemagnetic media (not shown and typically called a “hard drive”). Althoughnot shown, a magnetic disk drive for reading from and writing to aremovable, non-volatile magnetic disk (e.g., a “floppy disk”), and anoptical disk drive for reading from or writing to a removable,non-volatile optical disk such as a CD-ROM, DVD-ROM or other opticalmedia can be provided. In such instances, each can be connected to thebus by one or more data media interfaces. As will be further depictedand described below, memory 806 may include at least one program producthaving a set (e.g., at least one) of program modules that are configuredto carry out the functions of various embodiments of the application.

Program/utility 816, having a set (at least one) of program modules 818,may be stored in memory 806 by way of example, and not limitation, aswell as an operating system, one or more application programs, otherprogram modules, and program data. Each of the operating system, one ormore application programs, other program modules, and program data orsome combination thereof, may include an implementation of a networkingenvironment. Program modules 818 generally carry out the functionsand/or methodologies of various embodiments of the application asdescribed herein.

As will be appreciated by one skilled in the art, aspects of the presentapplication may be embodied as a system, method, or computer programproduct. Accordingly, aspects of the present application may take theform of an entirely hardware embodiment, an entirely software embodiment(including firmware, resident software, micro-code, etc.) or anembodiment combining software and hardware aspects that may allgenerally be referred to herein as a “circuit,” “module” or “system.”Furthermore, aspects of the present application may take the form of acomputer program product embodied in one or more computer readablemedium(s) having computer readable program code embodied thereon.

Computer system/server 802 may also communicate with one or moreexternal devices 820 such as a keyboard, a pointing device, a display822, etc.; one or more devices that enable a user to interact withcomputer system/server 802; and/or any devices (e.g., network card,modem, etc.) that enable computer system/server 802 to communicate withone or more other computing devices. Such communication can occur viaI/O interfaces 824. Still yet, computer system/server 802 cancommunicate with one or more networks such as a local area network(LAN), a general wide area network (WAN), and/or a public network (e.g.,the Internet) via network adapter 826. As depicted, network adapter 826communicates with the other components of computer system/server 802 viaa bus. It should be understood that although not shown, other hardwareand/or software components could be used in conjunction with computersystem/server 802. Examples, include, but are not limited to: microcode,device drivers, redundant processing units, external disk drive arrays,RAID systems, tape drives, and data archival storage systems, etc.

Although an exemplary embodiment of at least one of a system, method,and non-transitory computer readable medium has been illustrated in theaccompanied drawings and described in the foregoing detaileddescription, it will be understood that the application is not limitedto the embodiments disclosed, but is capable of numerous rearrangements,modifications, and substitutions as set forth and defined by thefollowing claims. For example, the capabilities of the system of thevarious figures can be performed by one or more of the modules orcomponents described herein or in a distributed architecture and mayinclude a transmitter, receiver or pair of both. For example, all orpart of the functionality performed by the individual modules, may beperformed by one or more of these modules. Further, the functionalitydescribed herein may be performed at various times and in relation tovarious events, internal or external to the modules or components. Also,the information sent between various modules can be sent between themodules via at least one of: a data network, the Internet, a voicenetwork, an Internet Protocol network, a wireless device, a wired deviceand/or via plurality of protocols. Also, the messages sent or receivedby any of the modules may be sent or received directly and/or via one ormore of the other modules.

One skilled in the art will appreciate that a “system” could be embodiedas a personal computer, a server, a console, a personal digitalassistant (PDA), a cell phone, a tablet computing device, a smartphoneor any other suitable computing device, or combination of devices.Presenting the above-described functions as being performed by a“system” is not intended to limit the scope of the present applicationin any way but is intended to provide one example of many embodiments.Indeed, methods, systems and apparatuses disclosed herein may beimplemented in localized and distributed forms consistent with computingtechnology.

It should be noted that some of the system features described in thisspecification have been presented as modules, in order to moreparticularly emphasize their implementation independence. For example, amodule may be implemented as a hardware circuit comprising custom verylarge-scale integration (VLSI) circuits or gate arrays, off-the-shelfsemiconductors such as logic chips, transistors, or other discretecomponents. A module may also be implemented in programmable hardwaredevices such as field programmable gate arrays, programmable arraylogic, programmable logic devices, graphics processing units, or thelike.

A module may also be at least partially implemented in software forexecution by various types of processors. An identified unit ofexecutable code may, for instance, comprise one or more physical orlogical blocks of computer instructions that may, for instance, beorganized as an object, procedure, or function. Nevertheless, theexecutables of an identified module need not be physically locatedtogether but may comprise disparate instructions stored in differentlocations which, when joined logically together, comprise the module andachieve the stated purpose for the module. Further, modules may bestored on a computer-readable medium, which may be, for instance, a harddisk drive, flash device, random access memory (RAM), tape, or any othersuch medium used to store data.

Indeed, a module of executable code could be a single instruction, ormany instructions, and may even be distributed over several differentcode segments, among different programs, and across several memorydevices. Similarly, operational data may be identified and illustratedherein within modules and may be embodied in any suitable form andorganized within any suitable type of data structure. The operationaldata may be collected as a single data set or may be distributed overdifferent locations including over different storage devices, and mayexist, at least partially, merely as electronic signals on a system ornetwork.

It will be readily understood that the components of the application, asgenerally described and illustrated in the figures herein, may bearranged and designed in a wide variety of different configurations.Thus, the detailed description of the embodiments is not intended tolimit the scope of the application as claimed but is merelyrepresentative of selected embodiments of the application.

One having ordinary skill in the art will readily understand that theabove may be practiced with steps in a different order, and/or withhardware elements in configurations that are different than those whichare disclosed. Therefore, although the application has been describedbased upon these preferred embodiments, it would be apparent to those ofskill in the art that certain modifications, variations, and alternativeconstructions would be apparent.

While preferred embodiments of the present application have beendescribed, it is to be understood that the embodiments described areillustrative only and the scope of the application is to be definedsolely by the appended claims when considered with a full range ofequivalents and modifications (e.g., protocols, hardware devices,software platforms etc.) thereto.

What is claimed is:
 1. A system, comprising: a blockchain networkcomprising a plurality of peer nodes programmed to store a blockchainand a state database comprising a plurality of key/value pairs; a newnode to be instantiated on the network, the new node programmed to:generate a state database checkpoint comprising a Merkle tree in whichone or more key-value pairs of a state database are mapped to one ormore leaf nodes of the Merkle tree, where the state database checkpointis created at a block number of the blockchain; determine that aplurality of peer nodes have reached a consensus on the state databasecheckpoint based on a root hash of the Merkle tree and respective roothashes broadcast by the plurality of peer nodes; construct an initialstate database from the state database checkpoint based on retrievedblocks of the blockchain; and execute transactions of the retrievedblocks on the initial state database to generate a current statedatabase; wherein the new node is programmed to extract and store theone or more key/value pairs from the one or more leaf nodes of theMerkle tree to construct the initial state database and to isolate theone or more leaf nodes that contain one or more discrepancies in one ormore of the plurality of key/value pairs.
 2. The system of claim 1wherein the new node is programmed to generate a Merkle tree for theinitial state database, wherein one or more key/value pairs of theinitial state database are stored in one or more leaf nodes of theMerkle tree for the initial state database.
 3. The system of claim 2wherein the new node is programmed to generate the Merkle tree inaccordance with a defined Merkle tree schema.
 4. The system of claim 2wherein the new node is programmed to: receive a consensus Merkle treeinto the new node; and compare hash values of one or more level nodes ofthe consensus Merkle tree and the Merkle tree generated by the new nodeto perform the isolation.
 5. The system of claim 1 wherein the new nodeis programmed to request the state database checkpoint and the blocks ofthe blockchain from an existing node of the blockchain network.
 6. Thesystem of claim 1 wherein the new node is programmed to generate asecond state database checkpoint at a next checkpoint interval number ofblocks of the blockchain and determine the new node as correctlyinstantiated if the second state database checkpoint matches a consensusstate database checkpoint.
 7. A method comprising: generating, via a newnode to be instantiated in a blockchain network, a state databasecheckpoint comprising a Merkle tree in which one or more key-value pairsof a state database are mapped to one or more leaf nodes of the Merkletree, where the state database checkpoint is created at a block numberof a blockchain of the blockchain network; determining that a pluralityof peer nodes have reached a consensus on the state database checkpointbased on a root hash of the Merkle tree and respective root hashesbroadcast by the plurality of peer nodes; constructing an initial statedatabase from the state database checkpoint based on retrieved blocks ofthe blockchain; and executing, at the new node, transactions of theretrieved blocks on the initial state database to generate a currentstate database; wherein the new node is programmed to extract and storethe one or more key/value pairs from the one or more leaf nodes of theMerkle tree to construct the initial state database and to isolate theone or more leaf nodes that contain one or more discrepancies in one ormore of the plurality of key/value pairs.
 8. The method of claim 7comprising generating a Merkle tree for the initial state database,wherein one or more key/value pairs of the initial state database arestored in one or more leaf nodes of the Merkle tree for the initialstate database.
 9. The method of claim 8 wherein the method furthercomprises generating the Merkle tree for the state database whichcomprises generating the Merkle tree in accordance with a defined Merkletree schema.
 10. The method of claim 8 comprising: receiving a consensusMerkle tree into the new node; and comparing hash values of one or morelevel nodes of the consensus Merkle tree and the Merkle tree generatedby the new node to perform the isolation.
 11. The method of claim 7comprising requesting, by the new node, the state database checkpointand the blocks of the blockchain from an existing node of the blockchainnetwork.
 12. The method of claim 7 comprising generating, by the newnode, a second state database checkpoint at a next checkpoint intervalnumber of blocks of the blockchain and determining the new node ascorrectly instantiated if the second state database checkpoint matches aconsensus state database checkpoint.
 13. A non-transitory computerreadable medium comprising instructions, that when read by a processor,cause the processor to perform: generating, via a new node to beinstantiated in a blockchain network, a state database checkpointcomprising a Merkle tree in which one or more key-value pairs of a statedatabase are mapped to one or more leaf nodes of the Merkle tree, wherethe state database checkpoint is created at a block number of ablockchain of the blockchain network; determining that a plurality ofpeer nodes have reached a consensus on the state database checkpointbased on a root hash of the Merkle tree and respective root hashesbroadcast by the plurality of peer nodes; constructing an initial statedatabase from the state database checkpoint based on retrieved blocks ofthe blockchain; and executing, at the new node, transactions of theretrieved blocks on the initial state database to generate a currentstate database; wherein the new node is programmed to extract and storethe one or more key/value pairs from the one or more leaf nodes of theMerkle tree to construct the initial state database and to isolate theone or more leaf nodes that contain one or more discrepancies in one ormore of the plurality of key/value pairs.
 14. The non-transitorycomputer readable medium of claim 13 comprising instructions that, whenexecuted, cause the at least one processor to perform requesting, by thenew node, the state database checkpoint and the blocks of the blockchainfrom an existing node of the blockchain network.
 15. The non-transitorycomputer readable medium of claim 13 comprising instructions that, whenexecuted, cause the at least one processor to perform generating, by thenew node, a second state database checkpoint at a next checkpointinterval number of blocks of the blockchain and determining the new nodeas correctly instantiated if the second state database checkpointmatches a consensus state database checkpoint.